package com.mvp.lt.airlineview.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.LatLng;
import com.amap.api.services.core.ServiceSettings;
import com.mvp.lt.airlineview.R;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.mvp.lt.airlineview.map.MapCreateManager;
import com.mvp.lt.airlineview.utils.LogUtil;
import com.mvp.lt.airlineview.utils.MapShadowManager;
import com.mvp.lt.airlineview.wayline.BandWayLineUtil;

import static com.mvp.lt.airlineview.App.getContext;

/**
 * 作者：uiho_mac
 * 时间：2018/6/7
 * 描述：显示地图
 * 版本：1.0
 * 修订历史：
 */
public class ShowMapActivity extends AppCompatActivity implements View.OnClickListener {
    @BindView(R.id.check_1)
    Button check1;
    @BindView(R.id.check_2)
    Button check2;
    @BindView(R.id.check_3)
    Button check3;
    @BindView(R.id.show_iv)
    ImageView showIv;
    private MapView mapView;
    private AMap aMap;

    private CheckBox mStyleCheckbox;
    public RelativeLayout mLll_layout;
    private int height = 120;
    private int fov = 85;
    public MapShadowManager mMapShadowManager;
    public BandWayLineUtil mStripLineWaypointManager;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_map);
        ButterKnife.bind(this);
        mLll_layout = findViewById(R.id.lll_layout);
        mapView = (MapView) findViewById(R.id.map);
        MapCreateManager.getMapManager().setMapView(this,mapView).buildMap(savedInstanceState);
        mStripLineWaypointManager = new BandWayLineUtil(MapCreateManager.getMapManager().getaMap());
        MapCreateManager.getMapManager().setOnMapClickListener(new AMap.OnMapClickListener() {
            @Override
            public void onMapClick(LatLng latLng) {
                LogUtil.e("Marker", "======onMapClick=====" + "" + latLng.latitude + "================" + latLng.longitude);
                // 113.02743681652198=====28.166934427802392
                // 113.02743681652198=====28.166934427802392
                mStripLineWaypointManager.addLatLngAddDrawWayLine(latLng);
            }
        });
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onResume() {
        super.onResume();
        mapView.onResume();
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onPause() {
        super.onPause();
        mapView.onPause();
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
        mStripLineWaypointManager.clearMap();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.basicmap:
                // 矢量地图模式
                aMap.setMapType(AMap.MAP_TYPE_NORMAL);
                break;
            case R.id.rsmap:
                // 卫星地图模式
                aMap.setMapType(AMap.MAP_TYPE_SATELLITE);
                break;
            case R.id.nightmap:
                //夜景地图模式
                aMap.setMapType(AMap.MAP_TYPE_NIGHT);
                break;
            case R.id.navimap:
                //导航地图模式
                aMap.setMapType(AMap.MAP_TYPE_NAVI);
                break;
            default:
                break;
        }
        mStyleCheckbox.setChecked(false);
    }


}
